package light.mvc.utils;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

/**
 * 
 * @author hqj
 *
 */
public class Highcharts {
	/**
	 * highcharts饼图
	 * @return
	 */
	public static String createPie(String text,String name,List<Object> list){
		
		StringBuilder sb = new StringBuilder("{");
		sb.append("\"chart\":{\"type\":\"pie\"},")
		.append("\"title\": {\"text\": \""+text+"\"},")
		.append("\"plotOptions\": {\"pie\": {\"allowPointSelect\": true,\"cursor\": \"pointer\",\"depth\": 35,\"dataLabels\": {\"enabled\": true}}},")
		.append("\"series\":[{\"name\": \""+name+"\",\"data\":"+JSON.toJSONString(list)+" }]");
		sb.append("}");
		return sb.toString();
	}
	
	public static String createColumn(String text,String categories,String series){
		StringBuilder sb = new StringBuilder("{");
		sb.append("\"chart\": {\"type\": \"column\"},")
		.append("\"title\": {\"text\": \""+text+"\"},")
		//.append("\"subtitle\": {\"text\": \""+subText+"\"},")
		.append("\"xAxis\": {\"categories\": "+categories+",\"crosshair\": true},")
		.append("\"yAxis\": {\"min\": -10,\"title\": {\"text\": \"y轴数值 (mm)\"}},")
		.append("\"plotOptions\": {\"column\": {\"pointPadding\": 0.2,\"borderWidth\": 0}},")
		.append("\"series\": "+series+"");
		sb.append("}");
		return sb.toString();
	}
	
	public static String createCombo(String text,String categories,String series,String html){
		StringBuilder sb = new StringBuilder("{");
		sb.append("\"title\": {\"text\": \""+text+"\"},")
		.append("\"xAxis\": {\"categories\": "+categories+"},")
		.append("\"labels\": {\"items\": [{\"html\": \""+html+"\",\"style\": {\"left\": \"50px\",\"top\": \"18px\"}}]},")
		.append("\"series\": "+series+"");
		sb.append("}");
		return sb.toString();
	}

}
